package com.geek.morning;

/**
 * @author SunBingJian
 * @desc TODO
 * @date 2025/9/2
 */
public class ForDemo {

    public static void main(String[] args) {

        //需求：输出1-100之间的奇数的和。（for）
        int sum1 = 0;
        for (int i = 1; i <= 100; i += 2) {
            sum1 += i;
        }
        System.out.println("输出1-100之间的奇数的和 = "+sum1);
        System.out.println("-----------------");

        //需求：输出1-100之间的偶数的和。（for）
        int sum2 = 0;
        for (int i = 2; i <= 100; i += 2) {
            sum2 += i;
        }
        System.out.println("输出1-100之间的偶数的和 = "+sum2);
    }
}
